package org.jsola.hr.web;

import org.jsola.core.Result;
import org.jsola.hr.constant.HrConstants;
import org.jsola.hr.dto.CostBillAddDTO;
import org.jsola.hr.service.ICostBillService;
import org.jsola.hr.vo.CostBillVO;
import org.jsola.user.core.TokenUser;
import org.jsola.user.core.UserContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;


/**
 * 费用账单
 *
 * @author zhr
 */
@RestController("hrCostBillSiteController")
@RequestMapping(HrConstants.API_PATH + "/v1/costBillSites")
public class CostBillSiteController implements ICostBillSiteControllerAPI {

    @Autowired
    private ICostBillService costBillService;

    @Override
    @PostMapping
    public Result<CostBillVO> generatedByCompanyIds(@Valid @RequestBody CostBillAddDTO costBillAddDTO) {
        TokenUser tokenUser = UserContext.getUser();
        // todo 查看项目权限校验

        return Result.success(
                costBillService.generatedByCompanyIds(costBillAddDTO, tokenUser)
        );
    }
}

